home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: SortPicts.h
- * -------------------
- *
- *
- *
- *
- *
- *
- *
- */
-
- #ifndef __SortPicts__
- #define __SortPicts__
-
- class SortPicts;
-
- #include "Window.h"
- #include "AppLib.h"
- #include <Threads.h>
- #include <QDOffscreen.h>
- #include <LowMem.h>
-
- /*
- * QuickSort #define
- */
- #define kPivotCutoff 25
-
- typedef void (*SortFuncPtr)( SortPicts *sortPicts);
- typedef void (*UpdateFuncPtr)( SortPicts *sortPicts);
-
- typedef unsigned char SortPixel;
- typedef SortPixel *SortPixelPtr;
- typedef SortPixelPtr *SortPixelHandle;
-
- typedef long SortData;
- typedef SortData *SortDataPtr;
- typedef SortDataPtr *SortDataHandle;
-
- #define kYieldTime 10
- #define kWindPictRectVoffset 20
- typedef double _Float;
-
- class SortPicts : public TWindow {
- public:
- GWorldPtr sortGWorld;
- PixMapHandle sortPixmap;
- SortPixelPtr sortPixels;
- SortDataPtr sortData;
- SortDataHandle sortHandle;
- long N;
- Rect updateRect;
- SortFuncPtr sortFunc;
- PicHandle sortPict;
- Rect sortRect;
- long pictWidth;
- long pictHeight;
- Rect copyBitsRect;
- Rect windPictRect;
- long pictRowBytes;
- WindowPtr me;
- long randomSeed;
- UpdateFuncPtr updateFunc;
- long startTime;
- long newUnitCount;
- long unitCount;
- ThreadID threadInfo;
-
- public:
- SortPicts();
- virtual ~SortPicts();
-
- virtual WindowPtr MakeNewWindow(WindowPtr behindWindow);
- virtual void AdjustCursor(EventRecord * anEvent);
- virtual void Activate(Boolean activating);
- virtual void Draw(void);
- // virtual void Click(EventRecord * anEvent);
- virtual void KeyDown(EventRecord * anEvent);
-
- virtual void AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
-
- virtual Boolean Close(void);
-
- virtual OSErr HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag);
- virtual OSErr HandleDrop(DragReference theDrag);
-
- Boolean PrepareGWorld( ConstStr255Param pictName);
-
- Boolean LoadPicture( ConstStr255Param pictName);
- Boolean MakeGWorld( void);
- Boolean AllocSortData( void);
- void MakeSortData( void);
- void UseSortData( void);
- void UnuseSortData( void);
- long Random( long num);
- long RandomPixel( void);
- void SetSortItem( long index, long data);
- void ExchangeSortItem( long one, long theOther);
- void Scramble( void);
-
- void UseUpdateFunc( UpdateFuncPtr updateFunc);
- void Update( void);
- void UpdateScramble( void);
- void UpdateSortPict( void);
-
- void Entry( void);
- void MakeThreaded( void);
- void Yield( void);
- void CalculateNewUnitCount( void);
-
- void UseSortFunc( SortFuncPtr sortFunc);
- void Sort( void);
- void QSort( void);
- void ChooseMedian( long a, long b, long c);
- void QuickSortEngine( long left, long right);
- };
-
- void UpdateScramble( SortPicts *sortPicts);
- void UpdateSortPict( SortPicts *sortPicts);
- void QSort( SortPicts *sortPicts);
-
- pascal void *SortPictsThreadEntry( void *there);
-
-
- #endif